// custom-tab-bar/index.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
        "list": [{
                "text": "首页",
                "iconPath": "/static/images/ic_menu_choice_nor.png",
                "selectedIconPath": "/static/images/ic_menu_choice_pressed.png",
                "pagePath": "pages/index/index"
            },
            {
                "text": "专题",
                "iconPath": "/static/images/ic_menu_topic_nor.png",
                "selectedIconPath": "/static/images/ic_menu_topic_pressed.png",
                "pagePath": "pages/subject/subject"
            },
            {
                "text": "分类",
                "iconPath": "/static/images/ic_menu_sort_nor.png",
                "selectedIconPath": "/static/images/ic_menu_sort_pressed.png",
                "pagePath": "pages/catalog/catalog"
            },
            {
                "text": "购物车",
                "iconPath": "/static/images/ic_menu_shoping_nor.png",
                "selectedIconPath": "/static/images/ic_menu_shoping_pressed.png",
                "pagePath": "pages/cart/cart"
            },
            {
                "text": "我的",
                "iconPath": "/static/images/ic_menu_me_nor.png",
                "selectedIconPath": "/static/images/ic_menu_me_pressed.png",
                "pagePath": "pages/my/my"
            }
        ],
        currentPath:"pages/index/index"
    },

    /**
     * 组件的方法列表
     */
    methods: {
        changeTab(event) {
            const idx = event.currentTarget.dataset.idx
            const item = this.data.list[idx]
            this.setData({
                currentPath: item.pagePath
            })
            wx.switchTab({
                url: '/' + item.pagePath,
            })
        }
    }
})